package com.bazaaroid.server.gae.core.enums;

public enum Languages {
	SERBIAN("sr", "LANGUAGE_SERBIAN"),
	ENGLISH("en", "LANGUAGE_ENGLISH");

	private String code;
	private String language;

	Languages(String code, String language) {
		this.code = code;
		this.language = language;
	}

	public String getCode() {
		return code;
	}

	public String getLanguage() {
		return language;
	}

	public static String getLanguageFromCode(String code) {
		String languageStr = "LANGUAGE_UNKNOWN";
		for(Languages lang : Languages.values())
			if(lang.getCode().equals(code))
				languageStr = lang.getLanguage();

		return languageStr;
	}

	public static boolean isSupportedLanguage(String code) {
		boolean isSupported = false;
		for(Languages lang : Languages.values())
			if(lang.getCode().equals(code))
				isSupported = true;

		return isSupported;
	}
}
